# 练习time 库和相关str 逻辑
import random
import time


# 说明信息
def showInfo():
    print("You are in a land full of dragons. In front of you, you see two caves. In one cave, the dragon is friendly "
          "\nand will share his treasure with you. The other dragon \n is greedy and hungry, and will eat you on "
          "sight.\nWhich cave will you go into? (1 or 2)")


def friendlyCave():
    return random.randint(0, 1)


def showCaveInfo():
    print('You approach the cave...')
    time.sleep(2)
    print('It is dark and spooky...')
    time.sleep(2)
    print('A large dragon jumps out in front of you! He opens his jaws and...')
    time.sleep(2)


def enterCave():
    choice = input()
    while choice != '1' and choice != '2':
        print("Which cave will you go into? (1 or 2)")
        choice = input()
    choice = int(choice)
    showCaveInfo()
    if choice == friendlyCave():
        print('Gives you his treasure!')
    else:
        print('Gobbles you down in one bite!')


def startGame():
    showInfo()
    enterCave()


if __name__ == '__main__':
    begin = "y"
    while begin == "yes" or begin == "y":
        startGame()
        print('Do you want to play again? (yes or no)')
        begin = input().lower()